#include <iostream>
#include  <stdio.h>
#include <math.h>
#include <stdlib.h>
typedef struct{
double re;
double im;
}Complex;
double modul(Complex);
double arg(Complex);
Complex adcomplex(Complex *a,Complex *b);
inline void print(Complex nr1);
Complex adcomplex(Complex a, Complex b);
Complex diff(Complex a, Complex b);
Complex* minus1(Complex *a,Complex *b);
Complex& dif(Complex a,Complex b);
bool equals(Complex a, Complex b);
bool null(Complex a);
const Complex zero ={0.0 ,0.0};
Complex nr1,nr2;
using namespace std;
int main()
{
	nr1.re=2.0;
	nr1.im=3.0;
	nr2.re=4.0;
	nr2.im=1.0;
	print(nr1);
	print(nr2);
	cout<<"\nModul nr1= "<<modul(nr1);
	cout<<"\nModul nr2= "<<modul(nr2);
	cout<<"\nArgumentul nr1= "<<arg(nr1);
	cout<<"\nArgumentul nr2= "<<arg(nr2);		
	Complex s=adcomplex(&nr1,&nr2);
	cout<<"\nAdunare folosind pointeri \n"<<"Re= "<<s.re<<" Im= "<<s.im;
	Complex s1=adcomplex(nr1,nr2);
	cout<<"\nAdunare simpla\n"<<"Re= "<<s1.re<<" Im= "<<s1.im;
	Complex dif1=diff(nr1,nr2);
	cout<<"\nScadere \n"<<"Re= "<<dif1.re<<"Im= "<<dif1.im; 
	if (equals(nr1,nr2))
		cout<<"\nNumerele sunt egale"<<endl;
	else
		cout<<"\nNumerele nu sunt egale"<<endl;	
	if (null(nr1))
		cout<<"\nNumarul este nul";
	else
		cout<<"\nNumarul nu este nul";
	Complex *re=minus1(&nr1,&nr2);
	cout<<"re="<<re->re<<"Im="<<re->im;
return 0;
}
double modul(Complex nr1)
{
double m;
m=sqrt(nr1.re*nr1.re+nr1.im*nr1.im);
return m;
}
double arg(Complex nr2)
{
return atan(nr1.im/nr1.re);
}
inline void print(Complex nr1)
{
	cout<<"Re="<<nr1.re<<endl<<"Im="<<nr1.im<<endl;
}

Complex adcomplex(Complex *a,Complex *b)
{
	double x,y;
	x=a->re+b->re;
	y=a->im+b->im;
	Complex s={x,y};
	return s;
}
Complex adcomplex(Complex a,Complex b)
{
	double x,y;
	x=a.re+b.re;
	y=a.im+b.im;
	Complex s={x,y};
	return s;
}
Complex diff(Complex a,Complex b)
{
	double x,y;
	x=a.re-b.re;
	y=a.im-b.im;
	Complex dif={x,y};
	return dif;
}
bool equals(Complex a, Complex b=zero)
{
	if ((a.re==b.re) && (a.im=b.im))
		return true;
	else
		return false;
}
bool null(Complex a)
{
	if (equals(a))
		return true;
	else
		return false;	


}
Complex* minus1(Complex *a,Complex *b)
{
	Complex *rez = malloc(sizeof(Complex));
	rez->re=a->re-b->re;
	rez->=a->im-b->im;
	
	return rez;

}

